﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Model;
using BLL;
namespace ClassSystem
{
    public partial class ASPAdmin查寝 : System.Web.UI.Page
    {
        TimeTableBLL bll = new TimeTableBLL();
        protected void Page_Load(object sender, EventArgs e)
        {
            this.Label1.Text = DateTime.Now.ToLongDateString().ToString();
            this.Repeater1.DataSource = bll.GetListAllChaqin();
            this.Repeater1.DataBind();
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                int RoomNo = Convert.ToInt32(this.TextBox1.Text.Trim());
                List<TimeTableModel> list = bll.GetListAllChaqin().Where(a => a.RoomNo == RoomNo).ToList();
                if (this.TextBox1.Text == "")
                {
                    this.Repeater1.DataSource = bll.GetListAllChaqin();
                    this.Repeater1.DataBind();
                }
                else
                {
                    if (list != null)
                    {
                        this.Repeater1.DataSource = list;
                        this.Repeater1.DataBind();
                    }
                    if (list.Count == 0)
                    {
                        Response.Write("<script>alert('查询失败！')</script>");
                    }
                }
            }
            catch (Exception)
            {

                throw;
            }


        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            string RoomCount = this.DropDownList1.SelectedValue;
            List<TimeTableModel> list = bll.GetListAllChaqin().Where(a => a.RoomCount == RoomCount).ToList();
            if (list != null)
            {
                this.Repeater1.DataSource = list;
                this.Repeater1.DataBind();
            }
            if (list.Count == 0)
            {
                Response.Write("<script>alert('查询失败！')</script>");
            }
        }
    }
}